////
//
/// \file ./include/inc/parser/ws_parser.hpp
//
//  Copyright 2007, 2008 Chandler Carruth
//
//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
//  use this file except in compliance with the License.  You may obtain a copy
//  of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
//  License for the specific language governing permissions and limitations
//  under the License.
//
////

#ifndef   inc_parser_ws_parser_header
#define   inc_parser_ws_parser_header

#include  <string>

#include  <boost/regex.hpp>
#include  <boost/scoped_ptr.hpp>

namespace inc {
namespace parser {

/// \brief  Basic white space parsing object.
/// \author Chandler Carruth
/// \date   2007.06.15
///
/// This class provides module-like parsing methods to parse whitespace.

class   WSParser
{
public:
  /// Iterator type for parsing
  typedef std::string::const_iterator iterator;

  /// Empty default constructor
  WSParser() {}

  /// Empty virtual destructor to enable inheritance and mocking
  virtual ~WSParser() {}

  virtual bool parse_ws( const iterator& first,
                         const iterator& last,
                         iterator& last_parsed );
  virtual bool parse_strict_ws( const iterator& first,
                                const iterator& last,
                                iterator& last_parsed );
  virtual bool parse_eol_ws( const iterator& first,
                             const iterator& last,
                             iterator& last_parsed );

protected:
  /// Facilitate dependency injection by subclasses.
  WSParser( boost::regex *ws_regex,
            boost::regex *strict_ws_regex,
            boost::regex *eol_ws_regex );

private:
  boost::scoped_ptr<boost::regex> ws_regex;
  boost::scoped_ptr<boost::regex> strict_ws_regex;
  boost::scoped_ptr<boost::regex> eol_ws_regex;

};

} //  end parser namespace
} //  end inc namespace
#endif  //  inc_parser_ws_parser_header
